
//回调地狱
// const fs = require('fs');

// fs.readFile('./resource/1.html', (err, data1) => {
//   fs.readFile('./resource/2.html', (err, data2) => {
//     fs.readFile('./resource/3.html', (err, data3) => {
//       console.log(data1.toString() + data2.toString() + data3.toString())
//     });
//   });
// });


//Promise.all
const fs = require('fs/promises');
let p1 = fs.readFile('./resource/1.html');
let p2 = fs.readFile('./resource/2.html');
let p3 = fs.readFile('./resource/3.html');

let result = Promise.all([p1, p2, p3]);

result.then(arr => {
  //拼接成字符串
  let res = arr.map(item => item.toString()).join('');
  //输出字符串
  console.log(res);
}, err => {})


//
// const fs = require('fs');
// let data1 = fs.readFileSync('./resource/1.html');
// let data2 = fs.readFileSync('./resource/2.html');
// let data3 = fs.readFileSync('./resource/3.html');
// console.log(data1.toString() + data2.toString() + data3.toString());






